/*
 *  MapElement.cpp
 *  Rempart
 *
 *
 */

#include "MapElement.h"
#include "Map.h"
#include <iostream>

bool MapElement::isMouseOver(){
	return this->mouseOver;
}
bool MapElement::isVisible(){
	return this->visible;
}


int MapElement::getWidth(){
	return MapElement::width;
}

int MapElement::getHeigth(){
	return MapElement::heigth;
}

int MapElement::getElementType(){
	return this->elementType;	
}



MapElement::MapElement(){
	this->elementType=0;
	this->checked = false;
	this->visible = false;
	this->secured = false;
	this->resetDefaultSurface();
}

MapElement::~MapElement(){
}


void MapElement::setMouseOver(bool collision){
	if(!this->isMouseOver()){
		this->mouseOver = true;
		this->visible = true;
		this->SetColor(sf::Color(255, 255, 255, 150));
		if(collision){
			this->SetImage(*RessourcesManager::getCollisionMouseOverSurface());
		}
		else {
			this->SetImage(*RessourcesManager::getDefaultMouseOverSurface());
		}

	}
}
void MapElement::unsetMouseOver(){
	if(this->isMouseOver()){
		this->mouseOver = false;
		this->resetDefaultSurface();
	}
}

void MapElement::resetDefaultSurface(){
		this->visible = false;
};


bool MapElement::isMouseOvered(){
	return this->mouseOver;
}

void MapElement::setVisible(){
	this->visible=true;
}
void MapElement::unsetVisible(){
	this->visible=false;
}

void MapElement::setChecked(){

	this->checked = true;
}
void MapElement::unsetChecked(){
	this->checked = false;

}
bool MapElement::isChecked(){
	return this->checked;
}
void MapElement::setSecured(){
	this->secured = true;
}
void MapElement::unsetSecured(){
	this->secured = false;
}
bool MapElement::isSecured(){
	return this->secured;
}

sf::Vector2<int>MapElement::getMapPosition(){
	
	return sf::Vector2<int>(this->GetPosition().x/MapElement::getWidth(),this->GetPosition().y/MapElement::getHeigth());
	
}
